Skip to content

test(github-backup): stubbed shell test for drain-wrapper.sh Bitwarden fallback branches (#5222) - #8658

Merged
dezren39 merged 1 commit into
mainfrom
queue/8957-5222-drain-test
Nov 11, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/8957-5222-drain-test

Conversation

@dezren39

@dezren39 dezren39 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds the missing test coverage for the github-backup drainer's Bitwarden credential fallback (#5222): infra/github-backup/systemd/drain-wrapper.test.sh, a stubbed shell test in the repo's shell-test conventions (cf. infra/dns/test_save_atomic.sh, lib/run-switch.test.sh), plus a scripts-test CI step in the run-switch pattern so it actually runs.

What is covered

The stub bws works only when BWS_ACCESS_TOKEN is exactly the stub token and serves the two secret names the wrapper fetches with fixed stub values; the drain entry point (../bin/drain_queue.py) is a stub that records the environment it was exec'd with. No real credential appears anywhere. Branches:

  1. Token already in the environment → drain runs with the fetched URL/bearer.
  2. Token only in ~/.config/bws/access-token → wrapper exports it, drain runs.
  3. Bare bws fails → ~/tools/bws-env.sh is sourced → bws works, drain runs.
  4. No branch works → exit 1, the exact "no working Bitwarden (bws) credential" error, drain never exec'd.
  5. Precedence: a good env token wins over a bad config file.

The wrapper is invoked via env -i with a controlled HOME/PATH: hosts that inject credential helpers into shells (exported functions / BASH_ENV) would otherwise supply a real token and defeat the stub — observed on the dev laptop, where the config-file case failed until the environment was cleaned.

Evidence

  • bash infra/github-backup/systemd/drain-wrapper.test.sh → 13/13 checks PASS, exit 0.
  • Neighbors still pass: lib/sops-atomic-writers.test.sh exit 0, lib/run-switch.test.sh exit 0.
  • drain-wrapper.sh itself is unchanged (the packet's exclude: no behavior change without a failing test showing a broken branch — all branches behave as documented).

Fleet task 8957 (lane any-a). The task's lane row was bound to a cleared legacy opencode session (ses_e5e37ae0456...; cleared 2026-11-11T02:02Z, flip refused), the prior user/review was reviewed by lane M (proceed, no Drew decision), and the pickup/blocking state is recorded on #5222 — this PR is the direct execution of the reviewed packet.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 11, 2026 11:41
@coderabbitai

coderabbitai Bot commented Nov 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ff19340d-1ddc-403d-8076-95e20011e33c
Commits

Reviewing files that changed from the base of the PR and between 3bb5289 and 5550bee.

Files selected for processing: 2

  • .github/workflows/scripts-test.yml
  • infra/github-backup/systemd/drain-wrapper.test.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T11:42:30.217572Z 5550bee PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39
dezren39 merged commit f192614 into main Nov 11, 2026
1 of 11 checks passed
@dezren39
dezren39 deleted the queue/8957-5222-drain-test branch November 11, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant